<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>{if isset($kupay_compay['seo']) && !empty($kupay_compay['seo']) }{$kupay_compay['seo']}{else/}工资条{/if}</title>
    <link rel="stylesheet" type="text/css" href="__CDN__/assets/addons/kupay/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="__CDN__/assets/addons/kupay/css/login.css"/>
    <script type="text/javascript" src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
    <script src="__CDN__/assets/libs/fastadmin-layer/dist/layer.js"></script>
</head>
<body>
<div class="">
    <div class=" flex-col">
        <div class="group1 flex-col">
            <div class="group2 flex-col">
                <span class="word2">员工登陆后即可查看工资条</span>
            </div>
            <span class="word3">欢迎登录</span>
            <div class="ImageText1 ">
                <div class="outer1 ">
                    <img  src="__CDN__/assets/addons/kupay/img/login_phone.png">
                </div>
                <div class="TextGroup1 ">
                    <input class="txt3" id="mobile"   value="" placeholder="请输入手机号"/>
                </div>
            </div>
            <div class="group3 ">
                <div class="mod2 ">
                    <img  src="__CDN__/assets/addons/kupay/img/login_code.png">
                </div>
                <div class="TextGroup2 ">
                    <input class="word4" id="code"  value="" placeholder="请输入验证码"/>
                </div>
                <div class="info1" id="timerout" onclick="sendcode()" >获取短信验证码</div>
            </div>
            <div class="group4 flex-col" onclick="next()"><span class="word5">确定</span></div>
        </div>
    </div>
</div>
<script>
    function next(){
        var mobile = $('#mobile').val();
        if(mobile=='' || mobile==undefined){
            layer.msg('请输入手机号！');return;
        }
        var code = $('#code').val();
        if(code=='' || code==undefined){
            layer.msg('请输入验证码！');return;
        }
        $.ajax( {
            url: "{:url('loginin')}",
            type: "POST",
            data:{'codes':code,phone:mobile},
            success: function(data){
                if(data.code==1){
                    window.location.href = "{:url('infolist')}";

                }else{
                    layer.msg(data.msg);
                }
            },
            error: function () {
                layer.msg('服务网络暂时有些小虫子（BUG），请找程序猿！', {time: 3000, icon:2});
            }
        });
    }
    //    倒计时
    var timeout = 60;
    var timer;
    function sendcode(){
        var mobile = $('#mobile').val();
        if(mobile=='' || mobile==undefined){
            layer.msg('请输入手机号！');return;
        }
        if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(mobile))){
            layer.msg("手机号不正确！");
            return false;
        }
        if(timeout==60){
            $.ajax( {
                url: "{:url('sendcode')}",
                type: "POST",
                data:{'phone':mobile},
                success: function(data){
                    if(data.error===0){
                        layer.msg('验证码发送成功。');
                        timer = setInterval("CountDown()", 1000);
                    }else{
                        layer.msg(data.msg);
                    }
                },
                error: function () {
                    layer.msg('服务网络暂时有些小虫子（BUG），请找程序猿！', {time: 3000, icon:2});
                }
            });
        }
    }
    function CountDown() {
        if (timeout > 0) {
            timeout -= 1;
            $('#timerout').html(timeout)
        } else{
            timeout = 60;
            clearInterval(timer);
            $('#timerout').html('获取短信验证码')
        }
    }
</script>
</body>
</html>
